package com.avocado.bt.impl.condition;

import com.avocado.bt.BTState;
import com.avocado.bt.IBTContext;
import com.avocado.bt.abs.condition.ConditionNode;
import com.avocado.mock.Player;

/**
 * 血量大于x
 *
 * @Author: zsh
 * @Date: 2023/10/16 19:17
 */
public class GTHpConditionNode extends ConditionNode {

    private final int hpLimit;

    public GTHpConditionNode(String param) {
        super(param);
        hpLimit = Integer.parseInt(param);
    }

    @Override
    public BTState doUpdate(IBTContext context) {
        Player player = context.getPlayer();
        if (player.getHp() >= hpLimit) {
            System.out.println("当前hp" + player.getHp() + " hp大于等于" + hpLimit);
            return BTState.Completed;
        } else {
            System.out.println("当前hp" + player.getHp() + " hp小于" + hpLimit);
            return BTState.Failure;
        }
    }

}
